package net.huashitong.ssydt.provider.money.service;

import net.huashitong.ssydt.money.entity.SsMoneyOrderDetail;
import net.huashitong.ssydt.provider.money.dto.DetailJoinOrderDTO;
import net.huashitong.ssydt.provider.money.mapper.SsMoneyOrderDetailMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author huiyang.yu
 */
@Service
@Transactional
public class SsMoneyOrderDetailServiceImpl implements SsMoneyOrderDetailService {

    private SsMoneyOrderDetailMapper mapper;

    public SsMoneyOrderDetailServiceImpl(SsMoneyOrderDetailMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public void save(SsMoneyOrderDetail ssMoneyOrderDetail) {
        mapper.save(ssMoneyOrderDetail);
    }

    @Override
    public void batchSave(List<SsMoneyOrderDetail> ssMoneyOrderDetails) {
        mapper.batchSave(ssMoneyOrderDetails);
    }

    @Override
    public List<SsMoneyOrderDetail> queryByOrderId(String orderId) {
        return mapper.queryByOrderId(orderId);
    }

    @Override
    public void batchUpdate(List<SsMoneyOrderDetail> ssMoneyOrderDetails) {
        for (SsMoneyOrderDetail ssMoneyOrderDetail : ssMoneyOrderDetails) {
            mapper.updateByPrimaryKeySelective(ssMoneyOrderDetail);
        }
    }

    @Override
    public List<SsMoneyOrderDetail> queryJoinOrderByUserIdWithGoodsIdWithGoodsType(String userId, Long goodsId, String goodsType) {
        DetailJoinOrderDTO dto = new DetailJoinOrderDTO(userId, goodsId, goodsType);
        return mapper.queryJoinOrderByUserIdWithGoodsIdWithGoodsType(dto);
    }
}
